import type {
  CategoryMaintenance,
  Maintenance,
  PageMaintenance,
  QueryPageByMaintenance,
  Result,
} from '@/config/data/data'
import { get, post } from './request'

/**
 * 分页查询你维修内容
 * @param data 分页参数
 * @returns 多条分页信息
 */
export const ReqSelectMaintenancePage = (
  data: QueryPageByMaintenance
): Promise<Result<PageMaintenance[]>> => get('/maintenance/page', data)

/**
 * 根据id查询维修内容
 * @param data 维修id
 * @returns 维修内容
 */
export const ReqSelectMaintenanceById = (data: {
  id: number
}): Promise<Result<Maintenance>> => get('/maintenance/detail', data)

/**
 * 新增维修订单
 * @param data 参数对象
 * @returns 是否成功
 */
export const ReqAddMaintenance = (
  data: Maintenance
): Promise<Result<boolean>> => post('/maintenance/add', data)

/**
 * 维修订单变更
 * @param data 参数对象
 * @returns 是否成功
 */
export const ReqPutMaintenanceById = (
  data: Maintenance
): Promise<Result<boolean>> => post('/maintenance/update', data)

/**
 * 根据分类id查询维修分类类目
 * @param data 分类id
 * @returns 多条分类信息
 */
export const ReqPutMaintenanceCategoryById = (data: {
  id: number
}): Promise<Result<CategoryMaintenance[]>> => get('/maintenance/category', data)
